package com.xiaozheng.jdbcDecoupling;

import java.sql.*;

/**
 * @Package: com.xiaozheng.jdbcDecoupling
 * @ClassName: jdbcDome
 * @Author: 小政同学    QQ:xiaozheng666888@qq.com
 * @CreateTime: 2020/9/19 17:25
 * @What_is_this_file_for: 这个文件是用来做什么的?
 * @Description: 描述
 */
public class jdbcDome {
    public static void main(String[] args) throws SQLException {
        DriverManager.registerDriver(new com.mysql.cj.jdbc.Driver());
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mybatis_spring?characterEncoding=utf8&serverTimezone=GMT","root","Zongroot");
        PreparedStatement statement = conn.prepareStatement("select * from user");
        ResultSet resultSet = statement.executeQuery();

        while (resultSet.next()) {
            System.out.print("id = " + resultSet.getInt("id")+"  ");
            System.out.print("username = " + resultSet.getString("username")+"  ");
            System.out.print("birthday = " + resultSet.getDate("birthday")+"  ");
            System.out.print("sex = " + resultSet.getString("sex")+"  ");
            System.out.print("address = " + resultSet.getString("address")+"  ");
            System.out.println();
        }

        resultSet.close();
        statement.close();
        conn.close();


    }
}
